package cn.edu.xjtu.android.emoji_warfare_android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * StartActivity<br>
 * 游戏选择界面
 * 
 * @author wyyf
 *
 */
public class StartActivity extends Activity {
    Button startEasy;
    Button startNormal;
    Button startHard;
    Button startEx;
    Button score;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        startEasy = (Button) findViewById(R.id.buttonEasy);
        startNormal = (Button) findViewById(R.id.buttonNormal);
        startHard = (Button) findViewById(R.id.buttonHard);
        startEx = (Button) findViewById(R.id.buttonEx);
        score = (Button) findViewById(R.id.buttonExit);
        OnClickListener start = new OnClickListener() {

            @Override
            public void onClick(View v) {
                int life = 0;
                String mode = "None";
                switch (v.getId()) {
                case R.id.buttonEasy:
                    life = 9;
                    mode = "简单";
                    break;
                case R.id.buttonNormal:
                    mode = "普通";
                    life = 4;
                    break;
                case R.id.buttonHard:
                    life = 2;
                    mode = "困难";
                    break;
                case R.id.buttonEx:
                    life = 0;
                    mode = "极限";
                    break;
                }
                Intent t = new Intent(StartActivity.this, MainActivity.class);
                t.putExtra("life", life);
                t.putExtra("mode", mode);
                t.putExtra("newGame", true);
                startActivity(t);
                finish();
            }
        };
        startEasy.setOnClickListener(start);
        startNormal.setOnClickListener(start);
        startHard.setOnClickListener(start);
        startEx.setOnClickListener(start);
        score.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                Intent t = new Intent(StartActivity.this, ScoreActivity.class);
                startActivity(t);
            }
        });
    }
}
